var util = require('../../../utils/util.js')
import tui from '../../../common/httpRequest'
const db = wx.cloud.database()

Page({
    data: {
        number: '',
        //
        name: '',
        info: '',
        intro: '',
        //
        slideBarWidth: 300,
        slideBlockWidth: 40,
        reset: 0,
        //
        items: [{
            title: "填写信息",
            desc: ""
        }, {
            title: "预约代拿",
            desc: ""
        }, {
            title: "向客服付款",
            desc: ""
        }, {
            title: "收货",
            desc: ""
        }],
        activeSteps: 1,
        flag: 0,
        //
        header: [{
                title: '单位/个',
                key: 'name'

            },
            {
                title: '小件',
                key: 'price1'

            },
            {
                title: '大件',
                key: 'price2'
            },
            {
                title: '超大件',
                key: 'price3'
            }
        ],
        listData: [{
                id: 1,
                name: '价格',
                price1: '1￥',
                price2: '2￥',
                price3: '不拿'
            },
            {
                id: 2,
                name: '说明',
                price1: '单手可拿',
                price2: '需双手拿',
                price3:'如：自行车，冰箱等'
            },

        ],
        content: '下单24小时内送达，急单请勿下单',
    },

    onLoad: function (options) {
        setTimeout(() => {
            this.init()
        }, 50)
    },
    init() {
        let sys = wx.getSystemInfoSync()
        this.setData({
            slideBarWidth: sys.windowWidth - tui.rpx2px(60),
            slideBlockWidth: tui.rpx2px(90)
        })
    },
    numInput: function (e) {
        this.setData({
            number: e.detail.value
        })
    },
    query: function () {
        var that = this;
        var number = that.data.number
        wx.navigateTo({
            url: `plugin://kdPlugin/index?num=${number}&appName=顺易通&title=顺易通全国物流信息`,
        })
    },
    success() {
        tui.toast("验证通过！")
        this.setData({
            flag: 1
        })
    },

    daina() {
        let data = this.data
        let flag = this.data.flag
        if (flag) {
            db.collection('express').add({
                // data字段表示需要新增的JSON数据
                data: {
                    name: data.name,
                    info: data.info,
                    intro: data.intro,
                    submitdate: db.serverDate()
                }
            }).then(res => {
                wx.showToast({
                    title: '提交成功',
                    icon: 'success',
                    duration: 2000
                })
            }).catch(console.error)
        } else {
            tui.toast("请先通过验证")
        }
    },

    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})